package com.example.hotel;

import java.io.InputStream;
import java.lang.reflect.Array;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xml.sax.helpers.ParserAdapter;

import android.R.bool;
import android.R.color;
import android.R.integer;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.os.StrictMode;
import android.renderscript.ProgramFragmentFixedFunction.Builder.Format;
import android.text.Html;
import android.text.Spanned;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class Services_list extends Activity implements OnClickListener {
	ArrayList<String> type_service_id = new ArrayList<String>();
	ArrayList<String> type_service = new ArrayList<String>();
	ArrayList<String> name = new ArrayList<String>();
	ArrayList<String> detail = new ArrayList<String>();
	ArrayList<String> price = new ArrayList<String>();
	ArrayList<String> image = new ArrayList<String>();

	int indexList = 0;
	ArrayList<String> price1 = new ArrayList<String>();
	ArrayList<Integer> indexCheck = new ArrayList<Integer>();
	ArrayList<String> type_service_id1 = new ArrayList<String>();

	public int displayPerPage = 6; // Display Perpage
	public int TotalRows = 0;
	public int indexRowStart = 0;
	public int currentPage = 1;
	TextView wellcome, name_menu;
	public int indexRowEnd = 0;

	public GridView gridV;
	public Button btnNext;
	public Button btnPre;
	public Button order;
	public CheckBox checkbox;
	String nameShop = "";
	Bitmap[] data = null;
	String[] check = null;
	ArrayList<HashMap<String, String>> myArrList;
	ImageView image_cart,image_msg,image_bill;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.services_list);
		if (android.os.Build.VERSION.SDK_INT > 9) {
			StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
					.permitAll().build();
			StrictMode.setThreadPolicy(policy);
		}

		
		TextView tvAmount = (TextView)findViewById(R.id.tvAmount);
		tvAmount.setText("("+((Global)getApplicationContext()).cart_count.toString()+")");
		ImageView home = (ImageView) findViewById(R.id.imagehome);
		home.setOnClickListener(this);
		wellcome = (TextView) findViewById(R.id.tvWellcome);
		wellcome.setText(((Global) getApplicationContext()).wellcome);
		name_menu = (TextView) findViewById(R.id.name_services);

		nameShop = ((Global) getApplicationContext()).nameShop;
		name_menu.setText(nameShop);
		getService_list();
		data = new Bitmap[image.size()];
		for (int i = 0; i < image.size(); i++) {
			String tmp = String.valueOf(image.get(i));
			Bitmap temp = getBitmapFromURL(tmp);
			if (temp != null) {
				data[i] = temp;
			}
		}
		gridV = (GridView) findViewById(R.id.gridView1);
		btnNext = (Button) findViewById(R.id.btnNext);
		btnPre = (Button) findViewById(R.id.btnPre);
		order = (Button) findViewById(R.id.order);
		image_cart= (ImageView) findViewById(R.id.image_cart);
		image_msg= (ImageView) findViewById(R.id.image_msg);
		image_bill= (ImageView) findViewById(R.id.image_bill);
		btnNext.setOnClickListener(this);
		btnPre.setOnClickListener(this);
		order.setOnClickListener(this);
		image_cart.setOnClickListener(this);
		image_msg.setOnClickListener(this);
		image_bill.setOnClickListener(this);

		myArrList = new ArrayList<HashMap<String, String>>();

		HashMap<String, String> map;
		String Servicesname = ((Global) getApplicationContext()).Servicesname;
		if (Servicesname.equals("food_list")) {
			for (int i = 0; i < type_service_id.size(); i++) {
				map = new HashMap<String, String>();
				map.put("id", type_service_id.get(i));
				map.put("Name", name.get(i));
				map.put("Detail", detail.get(i));
				map.put("Type", type_service.get(i));
				map.put("Price", price.get(i));
				map.put("ImagePath", image.get(i));
				myArrList.add(map);
			}
			progressShowData();

		} else if (Servicesname.equals("car_list")) {
			for (int i = 0; i < type_service_id.size(); i++) {
				map = new HashMap<String, String>();
				map.put("id", type_service_id.get(i));
				map.put("Name", name.get(i));
				map.put("Detail", detail.get(i));
				map.put("Price", price.get(i));
				map.put("ImagePath", image.get(i));
				myArrList.add(map);
			}
			progressShowData();

		} else {
			for (int i = 0; i < type_service_id.size(); i++) {
				map = new HashMap<String, String>();
				map.put("id", type_service_id.get(i));
				map.put("Detail", detail.get(i));
				map.put("Price", price.get(i));
				map.put("ImagePath", image.get(i));
				myArrList.add(map);
			}
			progressShowData();

		}
		/*------BackHome------*/
		ImageView back_home = (ImageView) findViewById(R.id.imagehome);
		back_home.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {

				startActivity(new Intent(Services_list.this, home.class));
				wellcome.setText(((Global) getApplicationContext()).wellcome);
			}
		});
		ImageView imageback = (ImageView) findViewById(R.id.imageback);
		imageback.setOnClickListener(new OnClickListener() {
			public void onClick(View arg0) {
				startActivity(new Intent(Services_list.this, Service.class));
				wellcome.setText(((Global) getApplicationContext()).wellcome);
			}
		});
		/*---------------------/
		
		
		/*------setfonts------*/
		Typeface Font = Typeface.createFromAsset(getAssets(),
				"fonts/PSL-Kittithada.ttf");
		Typeface FontBold = Typeface.createFromAsset(getAssets(),
				"fonts/PSL-KittithadaBold.ttf");
		TextView tv_amount = (TextView) findViewById(R.id.tvAmount);
		name_menu.setTypeface(FontBold);
		tv_amount.setTypeface(Font);
		wellcome.setTypeface(FontBold);
		btnNext.setTypeface(FontBold);
		btnPre.setTypeface(FontBold);
		order.setTypeface(FontBold);
		/*--------------------*/
	}

	public void onClick(View v1) {
		switch (v1.getId()) {
		case R.id.btnNext:
			currentPage = currentPage + 1;
			progressShowData();
			break;
		case R.id.btnPre:
			currentPage = currentPage - 1;
			progressShowData();
			break;
		case R.id.order:
			try {

				for (int i = 0; i < indexCheck.size(); i++) {

					((Global) getApplicationContext()).nameCart = "add_cart";
					((Global) getApplicationContext()).id_shopping = type_service_id1
							.get(i);
					((Global) getApplicationContext()).price_product = price1
							.get(i);
					getAdd_cart();
				}
				if (indexCheck.size() > 0) {

					((Global) getApplicationContext()).nameCart = "show_cart";
					startActivity(new Intent(Services_list.this, Add_cart.class));
				}

			} catch (Exception e) {
				//Toast.makeText(this, "pailin", Toast.LENGTH_LONG).show();
				// TODO: handle exception
			}
			break;
		case R.id.image_cart:
			((Global) getApplicationContext()).nameCart = "show_cart";
			((Global)getApplicationContext()).callpage ="Services_list";
			startActivity(new Intent(Services_list.this, Add_cart.class));
			break;
		case R.id.image_msg:
			((Global)getApplicationContext()).callpage ="Services_list";
			startActivity(new Intent(Services_list.this, Message_list.class));
			break;
		case R.id.image_bill:
			((Global)getApplicationContext()).callpage ="Services_list";
			startActivity(new Intent(Services_list.this, Billing_history.class));
			break;
		}
	}

	public void progressShowData()

	{
		// Total Record
		TotalRows = myArrList.size();
		// Start Index
		indexRowStart = ((displayPerPage * currentPage) - displayPerPage);
		int TotalPage = 0;
		if (TotalRows <= displayPerPage) {
			TotalPage = 1;
		}

		else if ((TotalRows % displayPerPage) == 0) {
			TotalPage = (TotalRows / displayPerPage);

		} else {
			TotalPage = (TotalRows / displayPerPage) + 1;
			TotalPage = (int) TotalPage;
		}
		// Disabled Button Next
		if (currentPage >= TotalPage) {
			btnNext.setEnabled(false);
		} else {
			btnNext.setEnabled(true);
		}
		// Disabled Button Previos

		if (currentPage <= 1) {
			btnPre.setEnabled(false);
		} else {
			btnPre.setEnabled(true);
		}
		// Show Data in GridView
		gridV.setAdapter(new Services_AdapterList(this));

	}

	private Bitmap getBitmapFromURL(String tmp) {
		// TODO Auto-generated method stub
		try {
			URL url = new URL(tmp);
			InputStream input = url.openConnection().getInputStream();
			BitmapFactory.Options options = new BitmapFactory.Options();
			Bitmap myBitmap = BitmapFactory.decodeStream(input, null, options);
			return myBitmap;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public class Services_AdapterList extends BaseAdapter {
		private Context context;

		public Services_AdapterList(Context c) {
			// TODO Auto-generated method stub
			context = c;
		}

		public int getCount() {

			// TODO Auto-generated method stub
			if (displayPerPage > TotalRows - indexRowStart) {
				return TotalRows - indexRowStart;
			} else {
				return displayPerPage;
			}
		}

		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		public View getView(final int position, View convertView,

		ViewGroup parent) {
			DecimalFormat decimalFormat = new DecimalFormat("###,##0.00");
			// //////setTextType///////
			String lang = ((Global) getApplicationContext()).lang;
			String txttype = "";
			if (lang.equals("th")) {
				txttype = "ประเภท : ";
			} else {
				txttype = "Type : ";
			}
			// TODO Auto-generated method stub
			Typeface FontBold = Typeface.createFromAsset(getAssets(),
					"fonts/PSL-KittithadaBold.ttf");
			// ColItemID
			String Servicesname = ((Global) getApplicationContext()).Servicesname;
			if (Servicesname.equals("food_list")) {
				LayoutInflater inflater = (LayoutInflater) context
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				if (convertView == null) {
					convertView = inflater.inflate(
							R.layout.services_food_column, null);
				}
				TextView Name = (TextView) convertView
						.findViewById(R.id.food_name);

				/*String txtname = myArrList.get(position + indexRowStart).get(
						"Name")
						+ txttype
						+ myArrList.get(position + indexRowStart).get("Type");
				Name.setText(txtname);*/
				Name.setText(myArrList.get(position + indexRowStart).get("Name"));
				
				Name.setTypeface(FontBold);

				TextView Type = (TextView) convertView
						.findViewById(R.id.type_name);
				Type.setText(txttype + myArrList.get(position + indexRowStart)
						.get("Type"));
				Type.setTypeface(FontBold);

				/*
				 * TextView Detail = (TextView) convertView
				 * .findViewById(R.id.detail_services); Detail.setLines(4);
				 * Detail.setText(myArrList.get(position + indexRowStart).get(
				 * "Detail")); Detail.setTypeface(FontBold);
				 */

				TextView Detail = (TextView) convertView
						.findViewById(R.id.detail_services);
				Detail.setLines(4);
				Detail.setText(myArrList.get(position + indexRowStart).get(
						"Detail"));
				Detail.setTypeface(FontBold);

				TextView Price = (TextView) convertView
						.findViewById(R.id.price_services);
				Double p = Double.parseDouble(myArrList.get(position + indexRowStart).get(
						"Price"));				
				Price.setText(decimalFormat.format(p)
						+ " THB");
				Price.setTypeface(FontBold);

				// ColPhoto
				ImageView Photo = (ImageView) convertView
						.findViewById(R.id.ColPhoto);
				String bm = myArrList.get(position + indexRowStart).get(
						"ImagePath");
				Bitmap temp = getBitmapFromURL(bm);
				if (temp != null) {
					Photo.setImageBitmap(temp);
				}
				final CheckBox checkbox = (CheckBox) convertView
						.findViewById(R.id.checkbox);
				if (indexCheck.size() > 0) {
					for (int i = 0; i < indexCheck.size(); i++) {
						int index = position + indexRowStart;
						if (indexCheck.get(i) == index) {
							checkbox.setChecked(true);
						}

					}
				}

				checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub
						indexList = position + indexRowStart;
						Boolean flage = true;
						if (indexCheck.size() > 0) {

							for (int i = 0; i < indexCheck.size(); i++) {
								if (indexList == indexCheck.get(i)) {
									type_service_id1.remove(i);
									price1.remove(i);
									checkbox.setChecked(false);
									indexCheck.remove(i);
									flage = false;
									break;
								}
							}
						}
						if (flage) {
							indexCheck.add(indexList);
							type_service_id1.add(myArrList.get(indexList).get(
									"id"));
							price1.add(myArrList.get(indexList).get("Price"));
							checkbox.setChecked(true);

						}
					}

				});

			} else if (Servicesname.equals("car_list")) {
				LayoutInflater inflater = (LayoutInflater) context
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				if (convertView == null) {
					convertView = inflater.inflate(R.layout.services_column,
							null);
				}
				TextView Detail = (TextView) convertView
						.findViewById(R.id.detail_services);
				Detail.setLines(4);
				Detail.setText(myArrList.get(position + indexRowStart).get(
						"Name")
						+ myArrList.get(position + indexRowStart).get("Detail"));
				Detail.setTypeface(FontBold);
				TextView Price = (TextView) convertView
						.findViewById(R.id.price_services);
				Double p = Double.parseDouble(myArrList.get(position + indexRowStart).get(
						"Price"));				
				Price.setText(decimalFormat.format(p)
						+ " THB");
				Price.setTypeface(FontBold);
				ImageView Photo = (ImageView) convertView
						.findViewById(R.id.ColPhoto);
				String bm = myArrList.get(position + indexRowStart).get(
						"ImagePath");
				Bitmap temp = getBitmapFromURL(bm);
				if (temp != null) {
					Photo.setImageBitmap(temp);
				}
				final CheckBox checkbox = (CheckBox) convertView
						.findViewById(R.id.checkbox);
				if (indexCheck.size() > 0) {
					for (int i = 0; i < indexCheck.size(); i++) {
						int index = position + indexRowStart;
						if (indexCheck.get(i) == index) {
							checkbox.setChecked(true);
						}

					}
				}			
				checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub\
						indexList = position + indexRowStart;
						Boolean flage = true;
						if (indexCheck.size() > 0) {

							for (int i = 0; i < indexCheck.size(); i++) {
								if (indexList == indexCheck.get(i)) {
									type_service_id1.remove(i);
									price1.remove(i);
									checkbox.setChecked(false);
									indexCheck.remove(i);
									flage = false;
									break;
								}
							}
						}
						if (flage) {
							indexCheck.add(indexList);
							type_service_id1.add(myArrList.get(indexList).get(
									"id"));
							price1.add(myArrList.get(indexList).get("Price"));
							checkbox.setChecked(true);
						}
					}
				});
			} else {
				LayoutInflater inflater = (LayoutInflater) context
						.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				if (convertView == null) {
					convertView = inflater.inflate(R.layout.services_column,
							null);
				}
				TextView Detail = (TextView) convertView
						.findViewById(R.id.detail_services);
				Detail.setLines(4);
				Detail.setText(myArrList.get(position + indexRowStart).get(
						"Detail"));
				Detail.setTypeface(FontBold);
				TextView Price = (TextView) convertView
						.findViewById(R.id.price_services);
				Double p = Double.parseDouble(myArrList.get(position + indexRowStart).get(
						"Price"));
				
				Price.setText(decimalFormat.format(p)
						+ " THB");
				Price.setTypeface(FontBold);
				ImageView Photo = (ImageView) convertView
						.findViewById(R.id.ColPhoto);
				String bm = myArrList.get(position + indexRowStart).get(
						"ImagePath");
				Bitmap temp = getBitmapFromURL(bm);
				if (temp != null) {
					Photo.setImageBitmap(temp);
				}

				final CheckBox checkbox = (CheckBox) convertView
						.findViewById(R.id.checkbox);
				if (indexCheck.size() > 0) {
					for (int i = 0; i < indexCheck.size(); i++) {
						int index = position + indexRowStart;
						if (indexCheck.get(i) == index) {
							checkbox.setChecked(true);
						}
					}
				}
				checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

					public void onCheckedChanged(CompoundButton buttonView,
							boolean isChecked) {
						// TODO Auto-generated method stub\
						indexList = position + indexRowStart;
						Boolean flage = true;
						if (indexCheck.size() > 0) {

							for (int i = 0; i < indexCheck.size(); i++) {
								if (indexList == indexCheck.get(i)) {
									type_service_id1.remove(i);
									price1.remove(i);
									checkbox.setChecked(false);
									indexCheck.remove(i);
									flage = false;
									break;
								}
							}
						}
						if (flage) {
							indexCheck.add(indexList);
							type_service_id1.add(myArrList.get(indexList).get(
									"id"));
							price1.add(myArrList.get(indexList).get("Price"));
							checkbox.setChecked(true);
						}
					}
				});
			}
			return convertView;
		}
	}

	public void getService_list() {
		String Servicesname = ((Global) getApplicationContext()).Servicesname;
		String URL1 = ((Global) getApplicationContext()).url;
		String SOAP_ACTION = ((Global) getApplicationContext()).soap_acction
				+ Servicesname;
		String NAMESPACE = "";
		String METHOD_NAME = Servicesname;
		String imei = ((Global) getApplicationContext()).imei;
		String lang = ((Global) getApplicationContext()).lang;
		String str = "";
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
		SoapObject responses = null;
		request.addProperty("id", imei);
		request.addProperty("lang", lang);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
		androidHttpTransport.debug = true;

		try {
			androidHttpTransport.call(SOAP_ACTION, envelope);
			responses = (SoapObject) envelope.bodyIn;
			str = responses.toString();

			if (Servicesname.equals("food_list")) {
				int indexSub = str.indexOf("=");
				String b = str.substring(indexSub + 1);
				String[] a = b.split("\\|");
				indexSub = a[a.length - 1].indexOf("}");
				b = a[a.length - 1].substring(0, indexSub - 2);
				a[a.length - 1] = b;
				for (int i = 0; i < a.length; i++) {
					String[] tmp = a[i].split("\\*");
					type_service_id.add(tmp[0]);
					String str1 = String.valueOf(Html.fromHtml(tmp[1]));
					name.add(str1);
					String str2 = String.valueOf(Html.fromHtml(tmp[2]));
					detail.add(str2);
					type_service.add(tmp[3]);
					price.add(tmp[4]);
					image.add(tmp[5]);

				}
			} else if (Servicesname.equals("car_list")) {
				int indexSub = str.indexOf("=");
				String b = str.substring(indexSub + 1);
				String[] a = b.split("\\|");
				indexSub = a[a.length - 1].indexOf("}");
				b = a[a.length - 1].substring(0, indexSub - 2);
				a[a.length - 1] = b;
				for (int i = 0; i < a.length; i++) {
					String[] tmp = a[i].split("\\*");
					type_service_id.add(tmp[0]);
					String str1 = String.valueOf(Html.fromHtml(tmp[1]));
					name.add(str1);
					String str2 = String.valueOf(Html.fromHtml(tmp[2]));
					detail.add(str2);
					price.add(tmp[3]);
					image.add(tmp[4]);

				}
			} else {
				int indexSub = str.indexOf("=");
				String b = str.substring(indexSub + 1);
				String[] a = b.split("\\|");
				indexSub = a[a.length - 1].indexOf("}");
				b = a[a.length - 1].substring(0, indexSub - 2);
				a[a.length - 1] = b;
				for (int i = 0; i < a.length; i++) {
					String[] tmp = a[i].split("\\*");
					type_service_id.add(tmp[0]);
					String str2 = String.valueOf(Html.fromHtml(tmp[1]));
					detail.add(str2);
					price.add(tmp[2]);
					image.add(tmp[3]);

				}
			}

		} catch (Exception e) {
			Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();

		}
	}

	public void getAdd_cart() {
		String URL1 = ((Global) getApplicationContext()).url;
		String nameCart = ((Global) getApplicationContext()).nameCart;
		String SOAP_ACTION = ((Global) getApplicationContext()).soap_acction
				+ nameCart;
		String NAMESPACE = "";
		String METHOD_NAME = nameCart;
		String lang = ((Global) getApplicationContext()).lang;
		String imei = ((Global) getApplicationContext()).imei;
		String product_id = ((Global) getApplicationContext()).id_shopping;
		String type_cart = ((Global) getApplicationContext()).type_cart;
		String price = ((Global) getApplicationContext()).price_product;
		SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
		SoapObject responses = null;
		request.addProperty("id", imei);
		request.addProperty("lang", lang);
		request.addProperty("product_id", product_id);
		request.addProperty("type", type_cart);
		request.addProperty("price", price);
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
				SoapEnvelope.VER11);
		envelope.dotNet = true;
		envelope.setOutputSoapObject(request);
		HttpTransportSE androidHttpTransport = new HttpTransportSE(URL1);
		androidHttpTransport.debug = true;

		try {
			androidHttpTransport.call(SOAP_ACTION, envelope);
			responses = (SoapObject) envelope.bodyIn;
			String str = responses.toString();
			int xx = 0;

		} catch (Exception e) {
			// Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();

		}
	}

	/*
	 * @Override protected void onSaveInstanceState(Bundle outState) { // TODO
	 * Auto-generated // method stub super.onSaveInstanceState(outState); //
	 * outState.putString("TEXT", (String)text.getText()); for (int i = 0; i <
	 * indexCheck.size(); i++) { Integer j = Integer.valueOf(indexCheck.get(i));
	 * LinearLayout itemLayout = (LinearLayout) gridV.getChildAt(j);
	 * 
	 * checkbox = (CheckBox) itemLayout.findViewById(R.id.checkbox);
	 * outState.putBoolean("item", checkbox.isChecked());
	 * 
	 * } }
	 * 
	 * @Override protected void onRestoreInstanceState(Bundle
	 * savedInstanceState) { // TODO // Auto-generated // method // stub
	 * super.onRestoreInstanceState(savedInstanceState); //
	 * text.setText(savedInstanceState.getString("TEXT")); for (int i = 0; i <
	 * indexCheck.size(); i++) { Integer j = Integer.valueOf(indexCheck.get(i));
	 * // LinearLayout itemLayout = (LinearLayout)gridV.getChildAt(j); checkbox
	 * = (CheckBox) gridV.getChildAt(j).findViewById( R.id.checkbox);
	 * checkbox.setClickable(savedInstanceState.getBoolean("item"));
	 * 
	 * } }
	 */

	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub

	}

	public void onCheckboxClicked(View view) {
		// Is the view now checked?
		boolean checked = ((CheckBox) view).isChecked();
		switch (view.getId()) {
		case R.id.checkBox:
			if (checked)
				break;
		}
	}

}
